package game;

public class Account {
		
		protected int beholdning; //declaring variable beholdning
		
		public Account() { //constructor account w/o parameters
			beholdning=3000; //methods body sets variable beholdning equal to 3000
		}
		
		public void deposit(int beloeb) { // method deposit with parameter beloeb void = do not return
			if (beloeb>=0) // if beloeb >=  
			beholdning += beloeb; // then previously declared beholdning+beloeb
		}
		
		public void withdraw(int belob)  // method withdraw with parameter belob void = do not return
		{
			if (belob<0) belob=(belob*(-1));  //if belob less than 0 multiplies -1 
			beholdning -= belob; // decalred beholdning -belob
			if (beholdning<0) { // if beholdning<0 then beholdning=0
				beholdning=0; 
			}
		}
		
		public void transfer(int belob, Player sp) //method transfer that shall not return. with 1 parameters and 1 object sp from class player
		{
			withdraw(belob); // calling method withdraw with parameter  belob 
			sp.deposit(belob); //method deposit for object sp  from class Player with parameter belob
		}
		
		public int getAccount() {  // getmethod that shall give result in int
			return beholdning;
		}
		
		public void nulstil() { //method nulstil that shall not return  w/o parameters
			beholdning=0;  // set variable beholdning to 0
		}
		// Test
}
